package com.michael.self.demompchart

import android.graphics.Color
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.github.mikephil.charting.charts.PieChart
import com.github.mikephil.charting.data.PieData
import com.github.mikephil.charting.data.PieDataSet
import com.github.mikephil.charting.data.PieEntry

class PieChartActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_pie_chart)
       val mPieChart= findViewById<PieChart>(R.id.pieChart)
        initChart(mPieChart)
    }

    private fun initChart(mPieChart: PieChart) {
        val list= mutableListOf<PieEntry>()
        for (i in 0..10) {
            list.add( PieEntry((10+i.toFloat()),""))
        }

       val mPieDataSet1= PieDataSet(list,"")
//        mPieDataSet1.color=Color.RED
       val mPieDataSet2= PieDataSet(list,"")
//        mPieDataSet2.color=Color.BLUE
        val mPieData =PieData()
        mPieData.addDataSet(mPieDataSet1)
        mPieData.addDataSet(mPieDataSet2)
        mPieChart.data=mPieData
    }
}